function AllReady() {
    const mstform = Ext.getCmp("CntPayM4")
    const Cycle = mstform.queryById("Cycle") // 统计周期
    var tabPanel = Ext.getCmp('tabPanel'); //获取当前所在tab页
    var CntPayD4 = tabPanel.getComponent('CntPayD4');
    tabPanel.setActiveTab(CntPayD4);
    var CntPayDChg4 = tabPanel.getComponent('CntPayDChg4');
    tabPanel.setActiveTab(CntPayDChg4);
    var CntPayDOut4 = tabPanel.getComponent('CntPayDOut4');
    tabPanel.setActiveTab(CntPayDOut4);

    if(otype=='add'){    
        getMonth()
    }
    function getMonth(){
        execServer("getInDate",{},function(res){
            if(res.count==0)return 
            const _data = JSON.parse(res.data)[0].extendObjects
            Cycle.setValue(_data.phid)
            BatchBindCombox([Cycle])
        })
    }   

        //判断项目类型如果是投资项目,设置表体CBS非必填

//     tabPanel.on('tabchange', function (tabPanel, newCard, oldCard, eOpts) {
//             console.log(newCard.id)
//             if (newCard.id == 'cntpaydIntab') {
//                 console.log('执行1');
//             }
//             if (newCard.id == 'cntpaydChgtab') {
//                 console.log('执行2');
           
//             }
//             if (newCard.id == 'cntpaydOuttab') {
//                 console.log('执行3');
    
//             }
//         });
        
   

setTimeout(()=>{
    //明细表通用帮助过滤
Ext.getCmp('CntPayD4').addListener("edit", function (editor, e) {
    //监听单据体编辑状态，edit-编辑；add-增行；cellclick-点击
    console.log(`测试++++++++++++++++++++++++`);
  //   if (e.field == "u_esjfl") {
  //     //监听字段变化
  //     var record = e.record;
  //     var data = dgrid.getSelectionModel().getSelection(); //获取当前选中行
  //     var u_esjfl = data[0].get("u_esjfl"); //获取当前选中行某个字段值
  //     dgrid
  //       .getColumn("u_yssjfl_name")
  //       .getEditor()
  //       .on("beforetriggerclick", function (eOp, ignoreBeforeEvent) {
  //         dgrid.getColumn("u_yssjfl_name").getEditor().setOutFilter({ phid_parent: u_esjfl }); //过滤另一个字段的选择项
  //       });
  //   }
  });
},1500)
}
// 格式化日期
function formatDate(dateStr, outputFormat) {
    const date = new Date(dateStr);

    if (isNaN(date)) {
        return "无效的日期字符串";
    }

    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0');
    const day = String(date.getDate()).padStart(2, '0');
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');

    let formattedDate;

    switch (outputFormat) {
        case "yyyy-mm-dd":
            formattedDate = `${year}-${month}-${day}`;
            break;
        case "yyyy-mm-dd HH:mm":
            formattedDate = `${year}-${month}-${day} ${hours}:${minutes}`;
            break;
        // 可以根据需要继续添加其他格式的处理逻辑
        default:
            formattedDate = "不支持的输出格式";
    }

    return formattedDate;
}